﻿using Model;
using Business.IFace;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MB.Orm.DB;
using Public.DataAccess;
using MB.RuleBase.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Business
{
    public class BUserCell
    {

        public List<UserCell> GetUserCellList(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<UserCell> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<UserCell>
                                                ("UserCell", "GetUserCellList", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }

        public int DeleteUserCell(int UserCellID)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQuery("UserCell", "DeleteUserCell", UserCellID);
        }

        public int AddUserCell(UserCell userCell)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<UserCell>
                            ("UserCell", "AddUserCell", userCell);
        }
        public int EditUserCellByID(UserCell userCell)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<UserCell>
                            ("UserCell", "EditUserCellByID", userCell);
        }
        public UserCell CheckUserCellPrimary(string UserCellID, int USERID, string CELLNO)
        {
            UserCellID = string.IsNullOrEmpty(UserCellID) ? "0" : UserCellID;
            UserCell Info = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<UserCell>("UserCell", "CheckUserCellPrimary"
                , USERID, CELLNO, int.Parse(UserCellID)).FirstOrDefault();
            return Info;
        }
    }
}
